package com.jin.flashsaled.result;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result {

    private Integer code;
    private String msg;
    private Object data;

    //成功返回不带数据
    public static Result success()
    {
        return new Result(ResultEnum.SUCCESS.getCode(),ResultEnum.SUCCESS.getMsg(), null);

    }

    //成功返回带数据
    public static Result success(Object data)
    {
        return new Result(ResultEnum.SUCCESS.getCode(),ResultEnum.SUCCESS.getMsg(), data);

    }


    //失败返回不带数据
    public static Result error(ResultEnum resultEnum)
    {
        return new Result(resultEnum.getCode(),resultEnum.getMsg(), null);

    }

    //失败返回带数据
    public static Result error(ResultEnum resultEnum,Object data)
    {
        return new Result(resultEnum.getCode(),resultEnum.getMsg(), data);

    }
}
